package com.italicatab;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.GridView;

public class MyGridView extends GridView{
	
	private Bitmap background;
	 
    public MyGridView(Context context, AttributeSet attrs) {
        super(context, attrs);
        background = BitmapFactory.decodeResource(getResources(), R.drawable.tiles_bg_smallera_new);
    }	
    
    @Override
    protected void dispatchDraw(Canvas canvas) {
        int count = getChildCount();
        int top = count > 0 ? getChildAt(0).getTop() : 0;
     int backgroundWidth = background.getWidth();
        int backgroundHeight = background.getHeight();
        int width = getWidth();
        int height = getHeight();


      /*  int backgroundWidth = getWidth();
        int backgroundHeight = getHeight();
        int width = getWidth();
        int height = getHeight();
*/
//        Log.e("image w-h", ""+backgroundWidth+" nd"+backgroundHeight);
//
//        Log.e("layout w-h", ""+width+" nd"+height);
        
        for (int y = top; y < height; y += backgroundHeight){
            for (int x = 0; x < width; x += backgroundWidth){
                canvas.drawBitmap(background, x, y, null);
            }
        }
     
        super.dispatchDraw(canvas);
    }
}
